package com.hnit.rol.show.mapper;

import com.hnit.rol.model.entity.bookInfo.BookInfo;
import com.hnit.rol.model.entity.bookShow.BookShow;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnit.rol.model.vo.bookShow.BookShowVo;
import com.hnit.rol.model.vo.order.OrderInfoVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author 86187
* @description 针对表【book_show】的数据库操作Mapper
* @createDate 2023-04-08 10:20:20
* @Entity com.hnit.rol.model.entity.bookShow.BookShow
*/
@Mapper
public interface BookShowMapper extends BaseMapper<BookShow> {


    @Select("select book_show.id,book_info.book_id bookId,book_name,book_type,book_pic,book_introduce,user_info.user_id userId,user_name,book_price,publish_time,down_time,book_status,book_num " +
            "from book_show,user_info,book_info where user_info.user_id=book_show.user_id and book_info.book_id=book_show.book_id order by publish_time desc ")
    @Results(value ={
            @Result(column = "id",property = "id"),
            @Result(column = "bookId",property = "bookId"),
            @Result(column = "book_name",property = "bookName"),
            @Result(column = "book_type",property = "bookType"),
            @Result(column = "book_pic",property = "bookPic"),
            @Result(column = "book_introduce",property = "bookIntroduce"),
            @Result(column = "userId",property = "userId"),
            @Result(column = "user_name",property = "userName"),
            @Result(column = "book_price",property = "bookPrice"),
            @Result(column = "publish_time",property = "publishTime"),
            @Result(column = "down_time",property = "downTime"),
            @Result(column = "book_status",property = "bookStatus"),
            @Result(column = "book_num",property = "bookNum")
    })
    List<BookShowVo> getAllBookShowList();

    @Select("select book_show.id,book_info.book_id bookId,book_name,book_type,book_pic,book_introduce,user_info.user_id userId,user_name,book_price,publish_time,down_time,book_status,book_num " +
            "from book_show,user_info,book_info " +
            "where user_info.user_id=book_show.user_id and book_info.book_id=book_show.book_id and (book_name like '%${condition}%' or book_type like '%${condition}%')" +
            "order by publish_time desc ")
    @Results(value ={
            @Result(column = "id",property = "id"),
            @Result(column = "bookId",property = "bookId"),
            @Result(column = "book_name",property = "bookName"),
            @Result(column = "book_type",property = "bookType"),
            @Result(column = "book_pic",property = "bookPic"),
            @Result(column = "book_introduce",property = "bookIntroduce"),
            @Result(column = "userId",property = "userId"),
            @Result(column = "user_name",property = "userName"),
            @Result(column = "book_price",property = "bookPrice"),
            @Result(column = "publish_time",property = "publishTime"),
            @Result(column = "down_time",property = "downTime"),
            @Result(column = "book_status",property = "bookStatus"),
            @Result(column = "book_num",property = "bookNum")
    })
    List<BookShowVo> getAllBookShowListByCondition(@Param("condition")String condition);

    @Select("select book_show.id,book_info.book_id bookId,book_name,book_type,book_pic,book_introduce,user_info.user_id userId,user_name,book_price,publish_time,down_time,book_status,book_num " +
            "from book_show,user_info,book_info " +
            "where user_info.user_id=book_show.user_id and book_info.book_id=book_show.book_id and book_type like '%${bookType}%' " +
            "order by publish_time desc ")
    @Results(value ={
            @Result(column = "id",property = "id"),
            @Result(column = "bookId",property = "bookId"),
            @Result(column = "book_name",property = "bookName"),
            @Result(column = "book_type",property = "bookType"),
            @Result(column = "book_pic",property = "bookPic"),
            @Result(column = "book_introduce",property = "bookIntroduce"),
            @Result(column = "userId",property = "userId"),
            @Result(column = "user_name",property = "userName"),
            @Result(column = "book_price",property = "bookPrice"),
            @Result(column = "publish_time",property = "publishTime"),
            @Result(column = "down_time",property = "downTime"),
            @Result(column = "book_status",property = "bookStatus"),
            @Result(column = "book_num",property = "bookNum")
    })
    List<BookShowVo> getAllBookShowListByBookType(@Param("bookType")String bookType);



}




